package com.itqf.beanfactory;

import com.itqf.pojo.Person;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * projectName: springframeworkgp8
 *
 * @author: 赵伟风
 * time: 2021/8/2 11:06
 * description:创建classpathxml容器
 */
public class ApplicationUse
{


    public static void main(String[] args) {

        /**
         * 创建一个读取xml文件容器
         *    构造参数: 可变参数,写入配置文件路径
         */
        ClassPathXmlApplicationContext applicationContext =
                new ClassPathXmlApplicationContext("spring/spring_ioc.xml");


        System.out.println("------------------------------");
        //获取bean
//        Object object =  applicationContext.getBean(beanid);
        //根据bean类型获取
        //Person bean = applicationContext.getBean(Person.class);
        Person person = applicationContext.getBean("person", Person.class);
        System.out.println("person = " + person);




        applicationContext.close();

        //applicationContext.getBeansOfType(); //返回这个类型bean集合

    }

}
